package com.music.wangyi.Base

import androidx.fragment.app.Fragment
import androidx.navigation.NavOptions
import androidx.navigation.fragment.findNavController
import com.music.wangyi.R


open class BaseFragment: Fragment() {
    // 共享跳转方法
    fun navigate(resId:Int){
        val navOptions = NavOptions.Builder()
            .setPopEnterAnim(R.anim.anim_enter)
            .setPopExitAnim(R.anim.anim_exit)
            .setEnterAnim(R.anim.anim_enter)
            .setExitAnim(R.anim.anim_exit)
            .build()
        val navController = findNavController()
        navController.navigate(resId,null,navOptions)
    }

    fun navigatePopUpTo(resId:Int,popUpId:Int){
        val navOptions = NavOptions.Builder()
            .setPopEnterAnim(R.anim.anim_enter)
            .setPopExitAnim(R.anim.anim_exit)
            .setEnterAnim(R.anim.anim_enter)
            .setExitAnim(R.anim.anim_exit)
            .setPopUpTo(popUpId,true)
            .build()
        val navController = findNavController()
        navController.navigate(resId,null,navOptions)
    }

}